package com.glory.nicleanrpt

import com.ivan.utils.PathUtil

/**
 * @Program: njcleanrpt
 * @Description: 返工
 * @Author: ivan
 */
class ReworkController {

    def dynamicQueryService

    def rework() {
        request.setCharacterEncoding("UTF-8")
        response.setContentType("text/html;charset=UTF-8")
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10, 20, 50, 100]
        def report_011 = []
        def tableHeadList = []
        def totalCount = 0
        // 返工类别
        params.SYS_QUERY_NAME = 'reworkTypeList'
        def reworkTypeList = dynamicQueryService.queryForList(params)
        // 返工工段
        params.SYS_QUERY_NAME = 'reworkStepList'    // stepList
        def reworkStepList = dynamicQueryService.queryForList(params)
        // 在制工段
        params.SYS_QUERY_NAME = 'wipStepList'   // stepList
        def wipStepList = dynamicQueryService.queryForList(params)
        def sysQueryName
        def sysQueryPath = PathUtil.getPath(this, request)
        if ('Excel'.equals(params.EXPORT_CONTENT_NAME)) {
            params.SYS_QUERY_NAME = 'reworkList'
            report_011 = dynamicQueryService.queryForList(params)
            if (report_011.size() > 0) {
                tableHeadList = report_011[0].keySet()
            }
            sysQueryName = params.SYS_QUERY_NAME
            params.SYS_QUERY_NAME = 'reworkCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
        }
        [
                pageCurrent    : pageCurrent,
                pageSize       : pageSize,
                pageSizeList   : pageSizeList,
                startno        : params.startno ?: '',
                endno          : params.endno ?: '',
                reworkStartTime: params.reworkStartTime ?: '',
                reworkEndTime  : params.reworkEndTime ?: '',
                srStartTime    : params.srStartTime ?: '',
                srEndTime      : params.srEndTime ?: '',
                fhStartTime    : params.fhStartTime ?: '',
                fhEndTime      : params.fhEndTime ?: '',
                reworkType     : params.reworkType ?: '',
                reworkStep     : params.reworkStep ?: '',
                wipStep        : params.wipStep ?: '',
                customName     : params.customName ?: '',
                deviceName     : params.deviceName ?: '',
                partName       : params.partName ?: '',
                markNum        : params.markNum ?: '',
                reworkTypeList : reworkTypeList,
                reworkStepList : reworkStepList,
                wipStepList    : wipStepList,
                report_011     : report_011,
                totalCount     : totalCount,
                tableHeadList  : tableHeadList,
                SYS_QUERY_PATH : sysQueryPath,
                SYS_QUERY_NAME : sysQueryName
        ]
    }
}